.Dd August 17, 2014
.Dt PICK 1
.Os
.Sh NAME
.Nm pick
.Nd fuzzy select anything
.Sh SYNOPSIS
.Nm
.Op Fl dKoSXx
.Op Fl q Ar query
.Sh DESCRIPTION
The
.Nm
utility allows users to select from a set of choices using an
.Xr curses 3
interface with fuzzy search functionality.
.Pp
The choices are read from
.Pa stdin ,
and the selected choice written to
.Pa stdout .
.Pp
The options are as follows:
.Bl -tag -width "-q query"
.It Fl d
Read and display descriptions.
Input lines will be split into two parts by the last occurrence of
.Ev IFS .
Both parts will be displayed but only the first part will be used when
searching.
.It Fl K
Disable toggling of keypad transmit mode.
Useful when running
.Nm
from within another interactive program which already has set the correct
transmit mode.
.It Fl o
Output description of selected choice on exit.
.It Fl q Ar query
Supply an initial search query.
.It Fl S
Disable sorting.
Only filter the choices instead of additionally sorting by score.
This option can be toggled from within the interface,
see
.Sx COMMANDS .
.It Fl x
Enable the use of the alternate screen terminal feature.
This is the default.
.It Fl X
Disable the use of the alternate screen terminal feature.
.El
.Sh COMMANDS
.Bl -tag -width XXXX
.It Ic Ctrl-C
Exit with a erroneous status without outputting the selected choice.
While this command often being defined as Ctrl-C it is determined by the
.Dv VINTR
control character,
see
.Xr termios 4 .
.It Ic Ctrl-L
Redraw interface with respect to the current size of the terminal.
.It Ic Ctrl-O
Toggle sorting.
.It Ic Up Ns / Ns Ic Down | Ic Ctrl-P Ns / Ns Ic Ctrl-N
Select between choices matching the current search query.
.It Ic Page-Down Ns / Ns Ic Page-Up | Ic Ctrl-V Ns / Ns Ic Alt-V | Ic Alt-Space
Move the selection to the choice located one page down/up from the currently
selected choice.
.It Ic Home Ns / Ns Ic End | Ic Alt-< Ns / Ns Ic Alt->
Move the selection to the first/last choice matching the current search query.
.It Ic Enter
Output the currently selected choice and exit.
.It Ic Alt-Enter
Output the current input query and exit.
.It Ic Left Ns / Ns Ic Right | Ic Ctrl-B Ns / Ns Ic Ctrl-F
Move the cursor left and right in the search query input field.
.It Ic Ctrl-A
Move the cursor to the beginning of the line in the search query input field.
.It Ic Ctrl-E
Move the cursor to the end of the line in the search query input field.
.It Ic Backspace | Ctrl-H
Delete one character to the left of the cursor in the search query input field.
.It Ic Delete | Ctrl-D
Delete the character under the cursor in the search query input field.
.It Ic Ctrl-W | Alt-Backspace
Delete the word to the left of the cursor.
A word is recognized as a sequence of characters for which either
.Xr isalnum 3
is true or the character is an underscore.
.It Ic Ctrl-U
Delete to the beginning of the line in the search query input field.
.It Ic Ctrl-K
Delete to the end of the line in the search query input field.
.It Ic Printable characters
Added to the search query and will refine the current search.
.El
.Sh ENVIRONMENT
The following environment variables will affect the execution of
.Nm pick :
.Bl -tag -width IFS
.It Ev IFS
Determines the separator used between choices and descriptions.
.El
.Sh ASYNCHRONOUS EVENTS
.Bl -tag -width "SIGWINCH"
.It Dv SIGWINCH
The screen is resized.
.El
.Sh EXAMPLES
Select a file in the current directory to open using
.Xr xdg-open 1 :
.Pp
.Dl $ find \&. -type f | pick | xargs xdg-open
.Pp
Select a command from the history to execute:
.Pp
.Dl $ eval $(fc -ln 1 | pick)
.Sh DIAGNOSTICS
.Ex -std
.Sh HISTORY
The first version of
.Nm
was released on August 18, 2014.
Development was sponsored by
.Lk https://thoughtbot.com thoughtbot
from the start of the project until September 2016.
.Sh AUTHORS
.An Calle Erlandsson Aq Mt calle@calleerlandsson.com
.An Anton Lindqvist Aq Mt anton@basename.se
